import { NgModule } from '@angular/core';
import { ExtraOptions, RouterModule, Routes } from '@angular/router';
import { LoginComponent } from './login/login.component';
import { SwiperPlayComponent } from './common/swiper-play/swiper-play.component';
import { RouteActivateChild } from './core/auth/route.activate.child';
import { LoginActivate } from './core/auth/login.activate';

const routes: Routes = [
  {
    path: 'login', component: LoginComponent
  },
  {
    path: 'pages', loadChildren: './pages/pages.module#PagesModule',
    canActivateChild: [RouteActivateChild],
    canActivate: [LoginActivate]
  },
  {
    path: 'play', component: SwiperPlayComponent,
    canActivate: [LoginActivate]
  },
  {path: '', redirectTo: 'login', pathMatch: 'full'},
  {path: '**', redirectTo: 'login'}
];

const config: ExtraOptions = {
  useHash: true
};

@NgModule({
  imports: [RouterModule.forRoot(routes, config)],
  exports: [RouterModule]
})
export class AppRoutingModule {
}
